#pragma once

#include "Panel.h"
#include "State.h"
#include "StateManager.h"
#include "Renderer.h"
#include "Drawable.h"
#include "Bat.h"
#include "Ball.h"
#include "Brick.h"
#include "Limiter.h"
#include "DrawList.h"
#include "Physics.h"
#include "Font.h"
#include "Brick.h"
#include "Level.h"
#include <vector>

class CGameState : public CState
{
public:
	~CGameState();

	// Implementation of specific events
	void getKeyPressed();
	bool Update(DWORD dwCurrentTime);
	void Draw();
	void OnBallOut();

	void Reset();
	bool IsGameOver()  { return m_bGameOver; }

	// Returns the single instance
	static CGameState* GetInstance(CStateManager* pManager, CRenderer* pRenderer, HDC hDC, HWND hWnd);

	//load board from file
	CLevel* LoadLevel(const char* szFileName);

	/* Key Values Vector
	 * [0] - player 1 move left
     * [1] - player 1 move right
	 * [2] - player 1 release ball
	 *
	 * [3] - player 2 move left
	 * [4] - player 2 move right
	 * [5] - player 2 release ball
	 */
	static std::vector<int> m_vKeyValues;
	static void CreateKeyVector();
	
	static bool m_bDynamicCamera;

	//options change routines:
	void SwitchDynamicCamera(bool bEnable);

protected:
	CGameState(CStateManager* pManager, CRenderer* pRenderer, HDC hDC, HWND hWnd);

private:
	CPhysics* m_pPhysics;		//holder for ODE routines
	CLevel* m_pLevel;
	CBall* pBall;				//temporary ball object
	CRenderer* m_pRenderer;		//pointer to render device object
	CDrawList* m_pDrawList;		//list with all drawable objects
	CBat* pBat[2];				//temporary player bats
	CLimiter* pLimiter[2];		//players' limiters
	CCamera* m_pCameras[3];		//cameras attached to game panel and players: (0 - panel, 1,2 - players)
	CPanel* m_pPanel;			//pointer to the game panel
	int m_iLevelNumber;			//current level number
	
	//drawing routines
	int RenderCameraView(CCamera* pCamera);
	int DrawWorld();

	//routines called by constructor/destructor
	int CreateNewGame();
	int DestroyGame();

	bool m_bGameOver;
};